package com.ldc.common.net;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.text.TextUtils;

import androidx.annotation.NonNull;

import com.ldc.common.model.BaseModel;
import com.ldc.common.utils.JsonUtils;
import com.ldc.common.utils.RxThreadUts;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.MediaType;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;

public class RequestLogStatusInterceptor implements Interceptor {

    public RequestLogStatusInterceptor() {


    }


    @NonNull
    @Override
    public Response intercept(Chain chain) throws IOException {
        final Request request = chain.request();
        final Response response = chain.proceed(request);
        final MediaType mediaType = response.body().contentType();
        final String content = response.body().string();
        //
        BaseModel<?> resultModel = JsonUtils.json2Bean(content, BaseModel.class);
        if (resultModel.notLogin()) {
            // 检测到未登录
        }
        //
        return response.newBuilder()
                .body(ResponseBody.create(content, mediaType))
                .build();
    }


}
